// https://leetcode.cn/problems/rotate-image/

/*
[
	[1, 2, 3],
	[4, 5, 6],
	[7, 8, 9],
]

*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
		int height = matrix.size();
		int top = 0;
		int bottom = height - 1;
		// 上下翻转
		while(top < bottom){
			for(int i = 0; i < height; i++){
				int tmp = matrix[top][i];
				matrix[top][i] = matrix[bottom][i];
				matrix[bottom][i] = tmp;
			}
			top++;
			bottom--;
		}
		// 对角线翻转
		for(int i = 0; i < height; i++){
			for(int j = 0; j < i; j++){
				int tmp = matrix[i][j];
				matrix[i][j] = matrix[j][i];
				matrix[j][i] = tmp;
			}
		}		
    }
};

int main(){
	vector<vector<int>> a = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
	cout << a.size() << endl;
	Solution so;
	so.rotate(a);
	for(auto items : a){
		for(auto item : items){
			cout << item << ",";
		}
		cout << endl;
	}
	return 0;
}